package net.xinqushi.socket.aio;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author xjie 2019/7/12 16:13
 * @description
 */
public class Server {
    public static void main(String[] args) {
        try {
            ServerSocket server = new ServerSocket(80);//bind local 80
            while (true){
                //thread block here
                Socket client = server.accept();//accept a client from wait queue , maximum size is 50
                BufferedReader input = new BufferedReader(new InputStreamReader(client.getInputStream()));
                //read from input
                int readBytes = 0;
                String readBuffer = new String();
                while( null != (readBuffer = input.readLine())){
                    //write readBytes to console
                    System.out.println(readBuffer);
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
